﻿<UserControl x:Class="TodoApp.Features.Home.Index"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:Transitions="clr-namespace:Phoenix.Frames.Transitions;assembly=Phoenix"
             xmlns:Transitions1="clr-namespace:Transitionals.Transitions;assembly=Transitionals"
             xmlns:Tasks="clr-namespace:TodoApp.Features.Tasks"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             d:DataContext="{d:DesignInstance Tasks:IndexViewModel}">

    <Transitions:TransitionService.NavigateForwardTransition>
        <Transitions1:FadeTransition />
    </Transitions:TransitionService.NavigateForwardTransition>
    <Transitions:TransitionService.NavigateBackTransition>
        <Transitions1:FadeTransition />
    </Transitions:TransitionService.NavigateBackTransition>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Button Foreground="{DynamicResource AccentColorBrush}"
                Style="{DynamicResource ChromelessButtonStyle}"
                FontSize="18"
                Command="{Binding CreateTaskCommand}"
                HorizontalAlignment="Left"
                Margin="5">
            <StackPanel Orientation="Horizontal">
                <Controls:MetroImage Source="{StaticResource appbar_add}"
                                     Foreground="{DynamicResource AccentColorBrush}"
                                     Width="16"
                                     Height="16"
                                     HorizontalAlignment="Center"
                                     VerticalAlignment="Center"
                                     Margin="3" />
                <Label VerticalAlignment="Center"
                       Content="_add task" />
            </StackPanel>
        </Button>

        <ScrollViewer Grid.Row="1"
                      Margin="12">
            <ItemsControl ItemsSource="{Binding Tasks}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border BorderBrush="{DynamicResource AccentColorBrush}"
                                BorderThickness="0 0 0 1">
                            <Grid>
                                <TextBlock Text="{Binding Title}"
                                           Foreground="{DynamicResource AccentColorBrush}"
                                           FontSize="18" />

                                <TextBlock Text="{Binding DueDate, TargetNullValue='No due date', StringFormat='Due on {0:d}'}"
                                           HorizontalAlignment="Right" />
                            </Grid>

                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>